#include "polymial_smooth.h"

void polymial_smooth_5_3(float32_t *in, float32_t *out, uint32_t len) {
    uint32_t i;
    if(len < 5U){
        for(i = 0U; i <= len - 1U; i++)
            out[i] = in[i];
    }else{
        out[0U] = (69.0F * in[0U] + 4.0F * in[1U] - 6.0F * in[2U] + 4.0F * in[3U] - in[4U]) / 70.0F;
        out[1U] = (2.0F * in[0U] + 27.0F * in[1U] + 12.0F * in[2U] - 8.0F * in[3U] + 2.0F * in[4U]) / 35.0F;
        for ( i = 2; i <= len - 3; i++ )
        {
            out[i] = (-3.0F * (in[i - 2U] + in[i + 2U])+ 12.0F * (in[i - 1U] + in[i + 1U]) + 17.0F * in[i] ) / 35.0F;
        }
        out[len - 2U] = (2.0F * in[len - 5U] - 8.0F * in[len - 4U] + 12.0F * in[len - 3U] + 27.0F * in[len - 2U] + 2.0F * in[len - 1U]) / 35.0F;
        out[len - 1U] = (- in[len - 5U] + 4.0F * in[len - 4U] - 6.0F * in[len - 3U] + 4.0F * in[len - 2U] + 69.0F * in[len - 1U]) / 70.0F;
    }
}
